package com.kakarote.examine.service;

import com.kakarote.core.entity.BasePage;
import com.kakarote.core.entity.UserInfo;
import com.kakarote.core.feign.examine.entity.*;
import com.kakarote.core.servlet.BaseService;
import com.kakarote.examine.entity.BO.*;
import com.kakarote.examine.entity.PO.Examine;
import com.kakarote.examine.entity.PO.ExamineRecord;
import com.kakarote.examine.entity.PO.ExamineRecordLog;
import com.kakarote.examine.entity.VO.*;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 审核记录表 服务类
 * </p>
 *
 * @author zhangzhiwei
 * @since 2020-11-19
 */
public interface IExamineRecordService extends BaseService<ExamineRecord> {

    public ExamineRecordReturnVO addExamineRecord(ExamineRecordSaveBO examineRecordSaveBO);

    /**
     * 进行审批，此方法采用异步同步的方式同步到其他模块
     *
     * @param examineBO data
     */
    public void auditExamine(ExamineBO examineBO);


    /**
     * 审批通过逻辑
     *
     * @param recordLog     审批记录日志
     * @param examineRecord 审批记录
     * @param userInfo      用户信息
     * @param examinePassBO 审批参数
     * @return 审核状态
     */
    Integer auditExaminePass(ExamineRecordLog recordLog, ExamineRecord examineRecord, UserInfo userInfo, ExaminePassBO examinePassBO, LocalDateTime examineTime);


    /**
     * 预览审批完整流程
     *
     * @param recordId
     * @param ownerUserId
     * @param outExamineEmail
     * @param outExamineStyle
     */
    public ExamineRecordVO queryExamineRecordList(Long recordId, Long ownerUserId, String outExamineEmail, Integer outExamineStyle);


    /**
     * 获取未结束审批流程的待审核人
     *
     * @param recordId
     */
    public ExamineRecordReturnVO queryExamineRecordInfo(Long recordId);

    /**
     * 删除审批记录以及自选人员
     *
     * @param recordId
     */
    Boolean deleteExamineRecord(Long recordId);

    /**
     * 修改审核记录状态
     *
     * @param recordId
     * @param examineStatus
     */
    Boolean updateExamineRecord(Long recordId, Integer examineStatus);

    /**
     * 根据类型批量删除历史记录 - 初始化数据专用
     * 有默认流程 故其他表未做清空处理
     *
     * @param label
     */
    Boolean deleteExamineRecordAndLog(Integer label);

    /**
     * 查询用户最近使用的审核
     *
     * @return
     */
    List<ExamineVO> recentlyUsedExamineList(Boolean isAdmin, Long userId, Long deptId);

    /**
     * 转交他人处理
     *
     * @param examineForwardOthersBO
     */
    public void forwardOthers(ExamineForwardOthersBO examineForwardOthersBO);

    /**
     * 超时未处理自动转交他人处理
     *
     * @param examineForwardOthersBO
     */
    public void autoForwardOthers(ExamineAutoForwardOthersBO examineForwardOthersBO);

    /**
     * 征求他人意见
     *
     * @param examineFlowFinalBO
     */
    public void solicitOthers(ExamineFlowFinalBO examineFlowFinalBO);

    /**
     * @return
     * @Description 获取个人审批统计表中的数据
     * @Author UNIQUE
     * @Date 2022/8/27
     * @Param
     **/
    BasePage<SuperExamineReportListVO> getSuperExamineReportList(SuperExamineReportSearchBO searchBO);

    /**
     * @return
     * @Description 获取个人审批统计表中的头统计数据
     * @Author UNIQUE
     * @Date 2022/8/28
     * @Param
     **/
    SuperExamineReportHeadVO getExamineReportInfo(SuperExamineReportSearchBO searchBO);

    void autoHandle(List<Long> recordIdList);


    BasePage<ExamineRecord> getExamineReportSubList(SuperExamineReportSubSearchBO searchBO);

    /**
     * 删除过期email 对外token
     *
     * @Author zyh
     * @Date 2022/8/28
     **/
    void removeInvalidEmailToken();

    public List<ExamineRecordCustomerVO> queryExamineRecordListByTypeId(Long typeId, Long ownerUserId);


    List<ExamineRecordLog> addExamineRecordLogList(Integer type, Long examineId, Integer examineStatus, Long flowId, Long recordId
            , Integer sortId, String msgContent, String examineName, Long recordTypeId, Integer passFlag, List<ExamineFlowFinalUser> userList);


    public void adminAuditExamine(ExamineAdminBO examineBO);


    public List<ExamineReturnFlowVO> adminExamineFlowId(ExaminePreviewBO examinePreviewBO);

    List<?> queryAuthField(ExamineBO examineBO);

    List<Map<String, Object>> queryExamineUpdateLog(ExamineBO examineBO);

    void addMessage(Examine examine, Integer examineType, String title, Long typeId, ExamineRecordLog examineLog, Long userId, boolean isUnusual, String examineReason, Integer isSendMessage);

    void addMessage(Examine examine, ExamineRecordLog examineLog, Long userId, String examineReason, Integer isSendMessage);
}
